<?php
//Start session
session_start();

//Include database connection details
require_once('../../inc/config.inc');

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

$query=mysql_query("INSERT INTO appointments VALUES(null,'".$_GET['a_date']."','".$_GET['a_time']."','".$_GET['a_type']."','".$_SESSION['USER_ID']."',null,'pending')");
if($query){
	header("location: ../index.php?add=success");
}
else{
	echo mysql_error();
}